<?php $this->pageTitle = 'Manage Custom Field Groups'; ?>

<div class="main-title main-title-with-tabs clearfix">
    <h1>Custom Field Groups</h1>
	<div class="main-title-tabs">
		<?php $this->widget('zii.widgets.CMenu', array('items' => array(
			array(
				'label' => 'Contact',
				'url' => array('customFieldGroup/', 'model' => 'Contact'),
				'active' => $customFieldModel == 'Contact'
			),
			array(
				'label' => 'User',
				'url' => array('customFieldGroup/', 'model' => 'User'),
				'active' => $customFieldModel == 'User'
			),
			array(
				'label' => 'Transaction',
				'url' => array('customFieldGroup/', 'model' => 'PropertyCase'),
				'active' => $customFieldModel == 'PropertyCase'
			),
		))); ?>
	</div>
</div>
<div class="grid_16 relative">
	<?php
	$this->widget('PsGridView', array(
		'id' => 'agency-customFieldGroups-grid',
		'dataProvider' => $dataProvider,
		'template' => '{pager}{items}{pagesize}',
		'pagesizeCssClass' => 'pager-pagesize',
		'pagerCssClass' => 'pager float-right',
		'rowCssClassExpression' => '',
		'selectableRows' => 0,
		'emptyText' => 'No custom fields groups defined',
		'columns' => array(
			'name' => array(
				'header' => 'Group Name',
				'name' => 'name',
				'value' => 'CHtml::link($data->name, array("customFieldGroup/update", "id" => $data->id), array("class" => "blue link"))',
				'type' => 'raw',
				'htmlOptions' => array(
					'class' => ''
				)
			),
			'custom_field_type' => array(
				'header' => 'Type',
				'name' => 'custom_field_type',
			),
			'default_value' => array(
				'header' => 'Default Value',
				'name' => 'default_value',
				'value' => '(empty($data->default_value))?"None":$data->default_value'
			),
			'pos',
			array(
				'header' => 'Actions',
				'class' => 'common.widgets.grid.PsActionColumn', // protected/components/PsActionColumn.php
				'htmlOptions' => array(
					'class' => 'action-column',
					'width' => '100'
				),
				'options' => array(
					'width' => 150
				),
				'actions' => array(
					'edit' => array(
						'label' => 'Edit',
						'icon' => '/images/icons/fugue/pencil.png',
						'class' => 'action-edit',
						'url' => array('customFieldGroup/update', 'id' => '$data->id'),
					),
					'remove' => array(
						'label' => 'Delete',
						'icon' => '/images/icons/fugue/cross-circle.png',
						'class' => 'action-delete',
						'onClick' => 'js:function(action) {return window.confirm("All the data in this field will be deleted. Are you sure?");}',
						'isAjax' => true,
						'loading' => 'Delete Custom Field...',
						'url' => array('customFieldGroup/delete', 'id' => '$data->id'),
						'onAjaxSuccess' => 'js:function(){$.fn.yiiGridView.update("agency-customFieldGroups-grid")}'
					),
				)
			),
		)
	));
	?>
	<div>
		<a class="blue link" href="<?php echo $this->createUrl('customFieldGroup/create', array('model' => $customFieldModel)); ?>">
			<img class="valign-middle" src="/images/icons/fugue/plus-button.png" />
			Add Custom Field Group
		</a>
	</div>
</div>